package cn.huiyunche.admin.tms.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.huiyunche.base.service.interfaces.TmsDAccidentService;
import cn.huiyunche.base.service.vo.DAccidentVo;
import cn.huiyunche.base.service.vo.PageVo;
import cn.huiyunche.base.service.vo.Result;
import cn.huiyunche.tools.basic.exceptions.BusinessException;

@Controller
@RequestMapping("/accident")
public class DAccidentController {

	private static final Logger LOGGER = LoggerFactory.getLogger(DAccidentController.class);

	@Autowired
	private TmsDAccidentService tmsDAccidentService = null;

	private TmsDAccidentService getTmsDAccidentService() {
		return this.tmsDAccidentService;
	}

	/**
	 * 查询事故列表
	 * 
	 * @param pageVo
	 * @param orderCode
	 * @return
	 * @throws Exception 
	 */
	@ResponseBody
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public Result<Map<String, Object>> list(PageVo pageVo, String orderCode) throws Exception {
		LOGGER.info("list params pageVo: {}, orderCode: {}", pageVo.toString(), orderCode);
		return this.getTmsDAccidentService().listAdmin(pageVo, orderCode);
	}

	/**
	 * 事故申报审核
	 * 
	 * @param id
	 * @param status
	 * @return
	 * @throws Exception 
	 */
	@ResponseBody
	@RequestMapping(value = "/auditaccident", method = RequestMethod.POST)
	public Result<Object> auditAccident(Long id, int status) throws Exception {
		LOGGER.info("auditAccident params id: {}, status: {}", id, status);
		return this.getTmsDAccidentService().auditAccident(id, status);
	}

	/**
	 * 查询事故记录图片
	 * 
	 * @param pageVo
	 * @return
	 * @throws Exception 
	 */
	@ResponseBody
	@RequestMapping(value = "/listpic", method = RequestMethod.GET)
	public Result<DAccidentVo> selectDAccident(Long waybillId) throws Exception {
		LOGGER.info("selectDAccident params waybillId: {}", waybillId);
		return this.getTmsDAccidentService().selectDAccident(waybillId);
	}

}